package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotWayPrice;
import com.gaohe.hotal.service.IHotWayPriceService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 价格方案设置Controller
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/hotal/price")
public class HotWayPriceController extends BaseController
{
    @Autowired
    private IHotWayPriceService hotWayPriceService;

    /**
     * 查询价格方案设置列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:price:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotWayPrice hotWayPrice)
    {
        startPage();
        List<HotWayPrice> list = hotWayPriceService.selectHotWayPriceList(hotWayPrice);
        return getDataTable(list);
    }

    /**
     * 导出价格方案设置列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:price:export')")
    @Log(title = "价格方案设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotWayPrice hotWayPrice)
    {
        List<HotWayPrice> list = hotWayPriceService.selectHotWayPriceList(hotWayPrice);
        ExcelUtil<HotWayPrice> util = new ExcelUtil<HotWayPrice>(HotWayPrice.class);
        util.exportExcel(response, list, "价格方案设置数据");
    }

    /**
     * 获取价格方案设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:price:query')")
    @GetMapping(value = "/{wayPriceId}")
    public AjaxResult getInfo(@PathVariable("wayPriceId") Long wayPriceId)
    {
        return success(hotWayPriceService.selectHotWayPriceByWayPriceId(wayPriceId));
    }

    /**
     * 新增价格方案设置
     */
    @PreAuthorize("@ss.hasPermi('hotal:price:add')")
    @Log(title = "价格方案设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotWayPrice hotWayPrice)
    {
        return toAjax(hotWayPriceService.insertHotWayPrice(hotWayPrice));
    }

    /**
     * 修改价格方案设置
     */
    @PreAuthorize("@ss.hasPermi('hotal:price:edit')")
    @Log(title = "价格方案设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotWayPrice hotWayPrice)
    {
        return toAjax(hotWayPriceService.updateHotWayPrice(hotWayPrice));
    }

    /**
     * 删除价格方案设置
     */
    @PreAuthorize("@ss.hasPermi('hotal:price:remove')")
    @Log(title = "价格方案设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wayPriceIds}")
    public AjaxResult remove(@PathVariable Long[] wayPriceIds)
    {
        return toAjax(hotWayPriceService.deleteHotWayPriceByWayPriceIds(wayPriceIds));
    }
}
